package com.ebc.eservice.controller.pc;

import com.ebc.eservice.service.EbcCardService;
import com.ebc.eservice.service.cardStat.CardStatService;
import com.ebc.eservice.util.JsonResult;
import com.ebc.eservice.util.common.constant.ApiTextHelperConstant;
import com.ebc.eservice.util.common.constant.DeveloperConstant;
import com.ebc.eservice.vo.ReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: Joey
 * @Description: 首页
 * @date:2022/10/9 16:14
 */
@Api(tags = "后台管理系统-首页")
@RestController
@RequestMapping("/home")
public class HomeController {
    @Autowired
    private CardStatService cardStatService;
    @Autowired
    private EbcCardService ebcCardService;

    //获取角色
    @ApiOperation(value = "获取近6个月访客总数趋势+客户总数趋势 arg: companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getVisitSixCurrent")
    public JsonResult getRoleList(@RequestBody ReqVo reqVo){
        System.out.println("获取近6个月访客总数趋势+客户总数趋势 id: "+reqVo.getCompanyId());
        return cardStatService.getSixMonthVisitStat(reqVo.getCompanyId());
    }

    @ApiOperation(value = "获取Top前三-员工-根据客户数量 arg: companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH +" flag=访客数量")
    @PostMapping("/getStaffList")
    public JsonResult getStaffList(@RequestBody ReqVo reqVo){
        System.out.println("获取Top前三-员工-根据客户数量 id: "+reqVo.getCompanyId());

        return ebcCardService.getTopThreeList(reqVo.getCompanyId());
    }

    //部门统计
    @ApiOperation(value = "获取一级部门统计 arg: companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getSectorStat")
    public JsonResult getSectorStat(@RequestBody ReqVo reqVo){
        return cardStatService.getSectorStat(reqVo.getCompanyId());
    }

    @ApiOperation(value = "获取二级部门统计 arg: companyId", notes = ApiTextHelperConstant.DEVELOPER + DeveloperConstant.FH)
    @PostMapping("/getSectorChildStat")
    public JsonResult getSectorChildStat(@RequestBody ReqVo reqVo){
        return cardStatService.getSectorChildStat(reqVo.getCompanyId());
    }

}
